package cn.itsource.ymcc.web.controller;

import cn.itsource.ymcc.dto.MobileDTO;
import cn.itsource.ymcc.result.JSONResult;
import cn.itsource.ymcc.service.IVerifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/verifycode")
public class VerifyCodeController {
    @Autowired
    private IVerifyService verifyService;

    @PostMapping("/sendSmsCode")
    public JSONResult sendSmsCode(@RequestBody @Valid MobileDTO dto){
        verifyService.sendSmsCode(dto);
        return new JSONResult();
    }

    @GetMapping("/imageCode/{key}")
    public JSONResult sendImage(@PathVariable String key){
            String base64Str = verifyService.sendImage(key);
            return JSONResult.success(base64Str);
    }
}
